#!/usr/bin/env node

const http = require('http');

const html = 
  ` <!DOCTYPE html>
    <html lang='en'>
       <head>
         <meta charset='UTF-8'>
         <title>登陆页面</title>
       <head>
       <body>
        <form action="">
        <label>用户名:</label>
           <input type="text" name="username">
        <br>
        <label>密码:</label>
        <input type="password" name='password'>
        <br>
          <input type="button" value='登录'>
        </form>

       </body>
  </html>`;

http.createServer((req,res)=>{

    if(req.url === '/') {
      res.writeHead(200, {
              'Content-Type': 'text/html',
              'Content-Lenght': Buffer.byteLength(html)
            
      });
          res.end(html);
            
    } else {
          res.statusCode = 404;
              res.setHeader('Content-Type', 'text/plain');
                  res.end('Resource not found!');
                    
    }

}).listen(8080);
